<?php $wo['terms'] = Wo_GetTerms(); ?>
<div class="container-fluid">
    <div class="block-header">
        <h2>页面 > 编辑条款页面</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-8 col-md-8">
            <div class="card">
                <div class="header">
                    <h2>编辑条款页面</h2>
                </div>
                <div class="body">
                    <div class="alert alert-success add-settings-alert"></div>
                    <form class="add-settings" method="POST">
                         <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="terms_of_use" id="terms_of_use" class="form-control" cols="30" rows="10"><?php echo $wo['terms']['terms_of_use'];?></textarea>
                                <label class="form-label">使用条款（允许HTML）</label>
                            </div>
                        </div>
                        <br>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="privacy_policy" id="privacy_policy" class="form-control" cols="30" rows="10"><?php echo $wo['terms']['privacy_policy'];?></textarea>
                                <label class="form-label">隐私政策（允许HTML）</label>
                            </div>
                        </div>
                        <br>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="about" id="about" class="form-control" cols="30" rows="10"><?php echo $wo['terms']['about'];?></textarea>
                                <label class="form-label">关于我们（允许HTML）</label>
                            </div>
                        </div>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">保存</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->
<script>

$(function() {
    var form_add_settings = $('form.add-settings');
    form_add_settings.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=update_terms_setting',
        beforeSend: function() {
            form_add_settings.find('.waves-effect').text('请稍后..');
        },
        beforeSubmit : function(arr, $form, options){
          delete arr[0];
          delete arr[1];
          delete arr[2];
          arr.push({name:'terms_of_use', value:btoa(unescape(encodeURIComponent($('#terms_of_use').val())))}); 
          arr.push({name:'privacy_policy', value:btoa(unescape(encodeURIComponent($('#privacy_policy').val())))});
          arr.push({name:'about', value:btoa(unescape(encodeURIComponent($('#about').val())))});
        },
        success: function(data) {
            if (data.status == 200) {
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.add-settings-alert').html('<i class="fa fa-check"></i> 页面保存成功');
            } else if (data.status == 400) {
	          alert(data.message);
	        }
	        form_add_settings.find('.waves-effect').text('保存');
        }
    });
});
</script>